<?php 
class OrderController extends CommonController{
	private $model;
	
	
	public function __init(){
		if(!session('uid')){
			go(U('Member/login'));
		}
		
		$this->model=K("Order");
		
	}
	
	public function index(){
		$oid=Q("get.oid",'','intval');
		if(!$oid){
			go(U('Index/index'));
		}
		
		$data=$this->model->where("oid={$oid}")->find();
		$oneday=24*60*60;
		$data['qxtime']=$data['time']+$oneday;
		$this->assign('data',$data);
		//如果用户在地址栏输入  检查oid是否存在  如果不存在跳转首页
		
		$this->display(); 	
	}
	
	public function addorder(){
		$number=Cart::getOrderId(); 
		$_POST['number']=$number;
		
		if(IS_POST){
			if(!$this->model->addorder()) $this->error($this->model->error);
			$this->success("提交成功",U('index',array('oid'=>$_POST['oid'])));
		}
		
	}
	
	/**
	 * 模拟支付
	 */
	public function paysuccess(){
		
		
		if(IS_POST){
			$data=array(
			     'oid'=>$_POST['oid'],
				 'status'=>'待收货'
			
			);
			$this->model->update($data);
			$this->success('支付成功',U('Index/index'));
			
		}
		
	}
	
	
	
	
}




 ?>